//
//  HYOnlineBarCell.m
//  HaiYue
//
//  Created by skyline on 2017/12/20.
//  Copyright © 2017年 skyline. All rights reserved.
//

#import "HYOnlineBarCell.h"
@interface HYOnlineBarCell()
@property (nonatomic, strong) HYImageView *IMG;
@property (nonatomic, strong) HYLabel *gameLBL;
@property (nonatomic, strong) HYLabel *tipsLBL;
@property (nonatomic, strong) HYLabel *yuyueLBL;
@end
@implementation HYOnlineBarCell
- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self)
    {
        self.backgroundColor = [UIColor whiteColor];
        self.IMG.image = [UIImage imageNamed:@"2"];
        self.gameLBL.hidden = self.tipsLBL.hidden = self.yuyueLBL.hidden = NO;
    }
    return self;
}

- (HYImageView *)IMG
{
    if (!_IMG)
    {
        _IMG = [[HYImageView  alloc]initWithCornerRadius:CornerRadius];
        [self addSubview:_IMG];
        [_IMG mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(self);
            make.centerX.equalTo(self);
            make.size.mas_equalTo(CGSizeMake(HYOnlineCellIMG_Width, HYOnlineCellIMG_Width));
        }];
    }
    return _IMG;
}

- (HYLabel *)gameLBL
{
    if (!_gameLBL)
    {
        _gameLBL = [[HYLabel alloc]initWithText:@"乱战三国" textColor:TEXT_BLACK_COLOR textFont:[UIFont systemFontOfSize:13]];
        [self addSubview:_gameLBL];
        [_gameLBL mas_updateConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(self.IMG.mas_bottom).with.offset(HYOnlineCellLBL_Gap * 2);
            make.centerX.equalTo(self);
        }];
    }
    return _gameLBL;
}

- (HYLabel *)tipsLBL
{
    if (!_tipsLBL)
    {
        _tipsLBL = [[HYLabel alloc]initWithText:@"1月1号首发" textColor:TEXT_GRAY_COLOR textFont:[UIFont systemFontOfSize:11]];
        [self addSubview:_tipsLBL];
        [_tipsLBL mas_updateConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(self.gameLBL.mas_bottom).with.offset(HYOnlineCellLBL_Gap * 2);
            make.centerX.equalTo(self);
        }];
    }
    return _tipsLBL;
}

- (HYLabel *)yuyueLBL
{
    if (!_yuyueLBL)
    {
        _yuyueLBL = [[HYLabel alloc]initWithText:@"预约" textColor:TEXT_GRAY_COLOR textFont:[UIFont systemFontOfSize:TipsFont weight:UIFontWeightLight]];
        _yuyueLBL.bounds = CGRectMake(0, 0, 60, 20);
        _yuyueLBL.layer.masksToBounds = YES;
        _yuyueLBL.layer.cornerRadius = _yuyueLBL.bounds.size.height / 2.0;
        _yuyueLBL.layer.borderColor = ORANGE_COLOR.CGColor;
        _yuyueLBL.layer.borderWidth = 0.5;
        _yuyueLBL.textAlignment = NSTextAlignmentCenter;
        [self addSubview:_yuyueLBL];
        [_yuyueLBL mas_updateConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(self.tipsLBL.mas_bottom).with.offset(HYOnlineCellLBL_Gap * 2);
            make.centerX.equalTo(self);
            make.size.mas_equalTo(self.yuyueLBL.bounds.size);
        }];
    }
    return _yuyueLBL;
}

- (void)setModel:(HYBookGameModel *)model
{
    if (_model != model)
    {
        _model = model;
        self.IMG.image = [UIImage imageWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:_model.img]]];
        self.gameLBL.text = _model.title;
        
    }
}
@end
